<?php
// server side example...
require_once 'sample_server_config.php';
// the sample service class...
class Sample_Service implements IService
{
    protected $_clientId = null;

    // required by the interface
    public function setClientId($clientId)
    {
        $this->_clientId = $clientId;

    }// end setClientId


    /**
     * foo function
     * @param str $bar
     * @return array
     */
    public function foo($bar)
    {
        // show the client id and request...
        // this returns an array, and as you may see, the client
        // will get this exact array...
        return array(
            'client_id' => $this->_clientId,
            'param'   => $bar
        );

    }// end foo

}// end Sample_Service



// start a server
$server = new SPRPC_Handler_Server;
// register a few functions and classes, in this example, the foo function that takes a bar
$server->register(new Sample_Service, 'foo');

// start listening
$server->listen();
?>